﻿using Microsoft.Extensions.Configuration;
using SageKing.Core.Abstractions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace SageKing.Core.Options;


public class ResourceWebClientApiOptions : IOptionsBase
{
    public string SectionName => typeof(ResourceWebClientApiOptions).Name;

    public string EndPointUrl { get; set; }

}
public class OpenIdBaseOptions : IOptionsBase
{
    public virtual string SectionName => typeof(OpenIdBaseOptions).Name;
    /// <summary>
    /// openid 颁发者
    /// </summary>
    public string Issuer { get; set; } = "https://localhost:7117/";
    public string ClientId { get; set; }
    public string ClientSecret { get; set; }
}

public class OpenIdClientOptions : OpenIdBaseOptions
{
    public override string SectionName => typeof(OpenIdClientOptions).Name;
}

public class OpenIdResourceOptions : OpenIdBaseOptions
{
    public override string SectionName => typeof(OpenIdResourceOptions).Name;
}
/// <summary>
/// 
/// </summary>
public class OpenIdServerOptions : OpenIdBaseOptions
{
    public override string SectionName => typeof(OpenIdServerOptions).Name;

    public string ConnectionString { get; set; } = null!;
    /// <summary>
    /// 重试次数，默认 5
    /// </summary>
    public int MaxRetryCount { get; set; } = 5;
    /// <summary>
    /// 重试超时（秒），默认30s
    /// </summary>
    public int MaxRetryDelay { get; set; } = 30;
    public DBTypeEnum DBType { get; set; } = DBTypeEnum.SqlServer;
    public string? MigrationsAssembly { get; set; }
    public bool IsTestingEnvironment { get; set; } = true;

    public bool DisableAccessTokenEncryption { get; set; } = false;

    public string AdminMailAddress { get; set; } = "admin@openiddict.com";
    public string AdminPwd { get; set; } = "Pass123$";

    public OpenIdResource ResourceServer { get; set; } = new OpenIdResource();


}

public class OpenIdResource
{
    /// <summary>
    /// Audience or ClientId
    /// </summary>
    public string ClientId { get; set; }
    public string ClientSecret { get; set; }
}

public enum DBTypeEnum
{
    SqlServer = 0,
    InMemory = 1,
    Sqlite = 2,
    MySql = 3,
    PostgreSQL = 4

}
